
package t4j.interfaces.classprocessor;

import java.util.Arrays;

class Processor{
	public String name(){
		return getClass().getSimpleName();
	}
	
	Object process(Object input){ return input;}
}

class Upcase extends Processor{
	String process(Object input){ 
		return ((String)input).toUpperCase();//向下转型
	}
}

class Downcase extends Processor{
	String process(Object input){ 
		return ((String)input).toLowerCase();//向下转型
	}
}

class Splitter extends Processor{
	String process(Object input){ 
		return Arrays.toString(((String)input).split(" "));
     }
}

public class Apply {

	public static String s="the class IS";
	
	public static void process(Object p , Object s){
		System.out.println("Using Processor " + ((Processor)p).name());
		System.out.println(((Processor)p).process(s));
	}
	
	public static void main(String[] args) {
		process(new Upcase(),s);
		process(new Downcase(),s);
		process(new Splitter(),s);
	}
}
